package cn.xd.common.enums.common;

import cn.xd.common.enums.IBaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author mirzaLin
 * @data 2023/11/13
 * @description 结果枚举-code
 **/
@Getter
@AllArgsConstructor
public enum ResultCodeEnum implements IBaseEnum<Integer> {
    SUCCESS(0, "成功"),

    VALIDATE_FAILED(404, "参数检验失败"),
    UNAUTHORIZED(401, "暂未登录或token已经过期"),
    FORBIDDEN(403, "没有相关权限"),

    PARAM_ERROR(-1, "参数验证错误"),
    BIZ_ERROR(-3, "业务异常"),

    /**
     * -100 未定义异常
     * -101 创建记录失败抛出
     * -102 更新记录失败抛出
     * -103 查询记录不应该为空时抛出
     */
    UNDEFINED_ERROR(-100, "服务器异常,请联系管理员:%s"),
    CREATE_ERROR(-101, "业务繁忙"),
    UPDATE_ERROR(-102, "业务繁忙"),
    QUERY_ERROR(-103, "服务器繁忙"),
    RE_TRY(-104, "连接超时,请重新操作一次"),
    IS_NOT_LOGIN(-401, "尚未登录"),
    REFRESH_QR_CODE(-431, "二维码失效,需要刷新"),
    INTERNAL_SERVER_ERROR(-500, "系统错误"),
    SYSTEM_MAINTAIN(-999, "系统维护中"),
    /**
     * 自定义错误
     */
    PLEASE_CONTACT_CUSTOMER_SERVICE(-1000, "请联系客服"),
    TOKEN_ERROR(-1001, "token登录错误"),
    UPLOAD_FILE_ERROR(-1002, "上传文件失败"),
    CHECK_PARAMS_ERROR(-1003, "效验参数失败"),
    /**
     * 第三方对接错误
     */
    FILE_CREATE_ERROR(-2000, "创建文件失败");
    private final Integer code;
    private final String info;

    public Integer getResult() {
        return code;
    }

    public String getDescription() {
        return info;
    }
}
